<?php
namespace Model;


use SDF\Db\MongoCollection;
use SMB\Goods\product;

class supplier_log extends MongoCollection
{
    public function __construct()
    {
        parent::__construct('supplier_log','supplier');
    }

    /*
     * $supplier_name 供应商姓名
     * $batch_num 操作对象
     * $describe  操做描述
     * $order_id  操作对象的id
     */
    public function add($supplier_name,$supplier_id,$describe,$order_id='',$sku_id='',$sign=''){
        $data['create_time'] = time();
        $data['create_name'] = $supplier_name;
        $data['describe'] = $describe;
        if(!empty($order_id)){
            $data['order_id'] = $order_id;
        }
        if(!empty($sku_id)){
            $data['sku_id'] = $sku_id;
        }
        if(!empty($sign)){
            $data['sign'] = $sign;
        }
        $data['supplier_id'] = $supplier_id;
        $supplier_log_db = new supplier_log();
        $result = $supplier_log_db->insert($data);
        if($result['ok']){
            return 1;
        }else{
            return 0;
        }
    }
    public function getSupplier_log(){
        $log_list = $this->find();
        $log_arr = array();
        foreach ($log_list as $v){
            if(isset($v['order_id']) && isset($v['sign'])){
                $log_arr[$v['supplier_id'.''].$v['order_id'].$v['sign']] = $v['create_time'];
            }
        }
        return $log_arr;
    }



}